{extend name='extra@admin/content'}

{block name="button"}
<a class="layui-btn layui-btn-danger " href="javascript:;" style="text-decoration: none"
   target="_blank" style="float:left;">数量：{$num}</a>
<a class="layui-btn layui-btn-danger " href="javascript:;" style="text-decoration: none"
   target="_blank" style="float:left;">成本：￥{$chengben}</a>
<a class="layui-btn layui-btn-danger " href="javascript:;" style="text-decoration: none"
   target="_blank" style="float:left;">利润：￥{$profit}</a>
<div class="nowrap pull-right" style="margin-top:10px">
    {if condition="$store_id != 0"}
        <a href='{:url("kuguan/storesale/export_salegoods")}?date={$Think.get.date}&store_id={$Think.get.store_id}' class="layui-btn layui-btn-small" style="text-decoration:none"><i class="fa fa-mail-forward"></i>
            导出
        </a>
    {else /}
        <a href="javascript:;" onclick="no_export();" class="layui-btn layui-btn-small " style="text-decoration:none;"><i class='fa fa fa-mail-forward'></i> 导出</a>
    {/if}
</div>
{/block}

{block name="content"}

<!-- 表单搜索 开始 -->
<form class="animated form-search" action="__SELF__" onsubmit="return false" method="get">
    <div class="col-xs-2">
        <div class="form-group">
            <select name="store_id"  lay-filter="export" class="input-sm form-control">
                <option value="">- 选择门店 -</option>
                {foreach store as $v1}
                <option value="{$v1.id}" {if $Think.get.store_id eq $v1.id} selected {/if}>{$v1.title}</option>
                {/foreach}
            </select>
        </div>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">下单时间</label>
        <div class="layui-input-inline">
            <input name="date" id='range-date' value="{$Think.get.date|default=''}"
                   placeholder="请选择时间" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-inline">
        <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
    </div>
</form>
<!-- 表单搜索 结束 -->

<form onsubmit="return false;" data-auto="true" method="post">
    {if $store_id == ''}
        <p class="help-block text-center well">请 选 择 查 询 的 门 店！</p>
    {else /}
    <table class="layui-table" lay-skin="line" lay-size="sm">
        <thead>
            <tr>
                <th class='text-left nowrap'>商品</th>
                <th class='text-left nowrap'>属性</th>
                <th class='text-left nowrap'>数量</th>
                <th class='text-left nowrap'>交易总价</th>
                <th class='text-left nowrap'>优惠</th>
                <th class='text-left nowrap'>成本</th>
                <th class='text-left nowrap'>利润</th>
            </tr>
        </thead>
        <tbody>
            {if !empty($list)}
            {volist name='list' id='vo'}
                <tr>
                    <td class='text-left nowrap'>
                        {$vo.name}
                    </td>
                    <td class='text-left nowrap'>
                        {if $vo.title == ''}
                            无属性
                        {else /}
                            {$vo.title}
                        {/if}
                    </td>
                    <td class='text-left nowrap'>
                        {$vo.goods_num}
                    </td>
                    <td class='text-left nowrap'>
                        {$vo.final_amount}
                    </td>
                    <td class='text-left nowrap'>
                        {if $vo.discount == ''}
                            0
                        {else /}
                            {$vo.discount}
                        {/if}
                    </td>
                    <td class='text-left nowrap'>
                        {if $vo.chengben == ''}
                            0
                        {else /}
                            {$vo.chengben}
                        {/if}
                    </td>
                    <td class='text-left nowrap'>
                        {if $vo.profit == ''}
                            0
                        {else /}
                            {$vo.profit}
                        {/if}
                    </td>
                </tr>
            {/volist}
            {else /}
                <tr>
                    <td class='text-center nowrap' colspan="4">暂 无 数 据！</td>
                </tr>
            {/if}
        </tbody>
    </table>
    {if isset($page)}<p>{$page}</p>{/if}
    {/if}
    <script>
        window.laydate.render({range: true, elem: '#range-date', format: 'yyyy/MM/dd'});

        /**
         * 不能导信息
         */
        function no_export(){
            layer.msg('请先选择门店',{icon: 2, time: 1500});
            return false;
        }
    </script>
</form>
{/block}